package com.imooc.ad.service.impl;



import com.imooc.ad.dao.CreativeRepository;
import com.imooc.ad.dao.unit_condition.CreativeUtilRepository;
import com.imooc.ad.entity.Creative;
import com.imooc.ad.service.ICreativeService;
import com.imooc.ad.vo.CreativeRequest;
import com.imooc.ad.vo.CreativeResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/*
 * @author Qihs
 */
@Service
public class CreativeServiceImpl implements ICreativeService {
    //必须记得，引入dao接口，需要先注解@Service
    private final CreativeRepository creativeRepository;

    @Autowired
    public CreativeServiceImpl(CreativeRepository creativeRepository) {
        this.creativeRepository = creativeRepository;
    }


    @Override
    public CreativeResponse createCreative(CreativeRequest request) {
        Creative creative = creativeRepository.save(
                request.convertToEntity());
        return new CreativeResponse(creative.getId(),creative.getName());
    }
}
